package demo.annotation.field;

import demo.annotation.PersonInfo;

import java.lang.reflect.Field;

public class Test {
	// 获取Field上的注解
	public static void main(String[] args) throws ClassNotFoundException {
		Class clazz = Class.forName("demo.annotation.Singer");
		Field[] fields = clazz.getDeclaredFields();
		for (Field field: fields){
			if(field.isAnnotationPresent(PersonInfo.class)){
				PersonInfo annotation = field.getAnnotation(PersonInfo.class);
				System.out.println("name,age = "+annotation.name()+","+annotation.age());
			}
		}
	}
}
